/**
 *  Copyright(C) 2007 Juri Strumpflohner
 *  All rights reserved
 *
 *  Created: 08.08.2007
*/

package com.aroundj2me.sandbox;

import java.util.Date;

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

import com.aroundj2me.model.DateUtility;

public class GeneralMidlet extends MIDlet {
	private Display display = null;
	
	public GeneralMidlet(){
	}
	
	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
		// TODO Auto-generated method stub

	}

	protected void pauseApp() {
		// TODO Auto-generated method stub

	}

	protected void startApp() throws MIDletStateChangeException {
		Form f = new Form("Hello");
		StringBuffer sb = new StringBuffer(60);

//		 Add the Configuration to the string that is the User-Agent value
		sb.append("Configuration/");
		sb.append(System.getProperty("microedition.configuration"));

//		 For each profile, append it to the User-Agent string
		String prof = System.getProperty("microedition.profiles");
		f.append("Profile: " + prof);
		int i = 0, j = 0;
		while ((j = prof.indexOf(' ', i)) != -1) {
		    sb.append(" Profile/");
		    sb.append(prof.substring(i, j));
		    i = j + 1;
		}
		sb.append(" Profile/");
		sb.append(prof.substring(i));

//		 Set the User-Agent field
		

		f.append(new StringItem("User-Agent", sb.toString()));
		display = Display.getDisplay(this);
		display.setCurrent(f);

	}
	
	public void showOnDisplay(Displayable d){
		this.display.setCurrent(d);
	}

}
